#pragma once

#include "png8cropfx.h"

namespace png8crop
{
	class ex_generic
	{
	private:
		static const int max_msg_len = 1024;
		const _TCHAR *const fmt;
		_TCHAR *msg, *msg2;

	public:
		ex_generic(const _TCHAR* msg);
		ex_generic(const _TCHAR* fmt, const _TCHAR* msg, const _TCHAR* msg2 = NULL);
		~ex_generic();

		const _TCHAR *const get_msg() const;
		const _TCHAR *const get_msg2() const;

		virtual void print_msg() const;

	public:
		static void msgcpy(_TCHAR * dst, int max_len, const _TCHAR* src);
	};

	class ex_io : public ex_generic
	{
	public:
		ex_io(const _TCHAR* detail)
			:ex_generic(_T("IO Exception (%s)."), detail){}
		ex_io(const _TCHAR* detail, const _TCHAR* param)
			:ex_generic(_T("IO Exception (%s): \"%s\""), detail, param){}
	};

	class ex_dataformat : public ex_generic
	{
	public:
		ex_dataformat(const _TCHAR* detail)
			:ex_generic(_T("Data Exception (%s).\n"), detail){}
		ex_dataformat(const _TCHAR* detail, const _TCHAR* param)
			:ex_generic(_T("Data Exception (%s): \"%s\".\n"), detail, param){}
	};

	class ex_unknown : public ex_generic
	{
	public:
		ex_unknown(const _TCHAR* detail)
			:ex_generic(_T("Unknown Exception (%s).\n"), detail){}
		ex_unknown(const _TCHAR* detail, const _TCHAR* param)
			:ex_generic(_T("Unknown Exception (%s): \"%s\".\n"), detail, param){}
	};

	class ex_internal : public ex_generic
	{
	public:
		ex_internal(const _TCHAR* detail)
			:ex_generic(_T("Internal Exception (%s).\n"), detail){}
		ex_internal(const _TCHAR* detail, const _TCHAR* param)
			:ex_generic(_T("Internal Exception (%s): \"%s\".\n"), detail, param){}
	};

}